<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>问题跟踪系统</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.min.css">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
</head>
<body>
    <!-- 导航栏 - 移除不必要的容器边距 -->
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark sticky-top">
        <a class="navbar-brand ml-3" href="{{ url_for('main.list_issues') }}">问题跟踪系统</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav mr-auto">
                {% if current_user.is_authenticated %}
                <li class="nav-item active">
                    <a class="nav-link" href="{{ url_for('main.list_issues') }}">问题列表 <span class="sr-only">(current)</span></a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="{{ url_for('main.create_issue') }}">创建问题</a>
                </li>
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="aiDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                        AI知识库
                    </a>
                    <div class="dropdown-menu" aria-labelledby="aiDropdown">
                        <a class="dropdown-item" href="{{ url_for('main.ai_search') }}">AI搜索</a>
                        <a class="dropdown-item" href="{{ url_for('main.ai_dashboard') }}">AI仪表板</a>
                    </div>
                </li>
                {% endif %}
            </ul>
            <ul class="navbar-nav ml-auto mr-3">
                {% if current_user.is_authenticated %}
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                        {{ current_user.username }}
                    </a>
                    <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
                        <a class="dropdown-item" href="#">个人资料</a>
                        <div class="dropdown-divider"></div>
                        <a class="dropdown-item" href="{{ url_for('main.logout') }}">退出登录</a>
                    </div>
                </li>
                {% else %}
                <li class="nav-item">
                    <a class="nav-link" href="{{ url_for('main.login') }}">登录</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="{{ url_for('main.register') }}">注册</a>
                </li>
                {% endif %}
            </ul>
        </div>
    </nav>

    <!-- 主内容区域 - 添加flex布局支持 -->
    <main class="container mt-4 flex-grow-1">
        {% with messages = get_flashed_messages(with_categories=true) %}
            {% if messages %}
                {% for category, message in messages %}
                    <div class="alert alert-{{ category }} fade show" role="alert">
                        {{ message }}
                        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                {% endfor %}
            {% endif %}
        {% endwith %}

        {% block content %}
        {% endblock %}
    </main>

    <!-- 页脚 - 固定在底部 -->
    <footer class="footer bg-light py-3">
        <div class="container text-center">
            <span class="text-muted">&copy; 2025 润得科技问题跟踪系统</span>
        </div>
    </footer>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/js/bootstrap.min.js"></script>
    <script src="{{ url_for('static', filename='js/main.js') }}"></script>
</body>
</html>